package com.doget.comment.utils;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.graphics.PointF;
import android.util.Log;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.TranslateAnimation;

public class AnimationUtils {

    public void playWithAfter(View view,float screenWidth,float screenHeight) {

        ObjectAnimator animator1 = ObjectAnimator.ofFloat(view, "scaleY", 1, 0);//沿着Y轴放大
        ObjectAnimator animator2 = ObjectAnimator.ofFloat(view, "scaleX", 1, 0);//沿着X轴放大
        ObjectAnimator animator3 = ObjectAnimator.ofFloat(view, "translationX", 0.0f,screenWidth/2);//沿着x轴平移
        ObjectAnimator animator4 = ObjectAnimator.ofFloat(view, "translationY", 0.0f, screenHeight/2);//沿着Y轴平移

        ObjectAnimator animator22 = ObjectAnimator.ofFloat(view, "translationY", 0.0f, 350.0f, 0.0f);//沿着Y轴平移
        animator3.setInterpolator(new LinearInterpolator());
        animator4.setInterpolator(new AccelerateInterpolator());

//        animator2.setStartDelay(1000);
//        animator3.setStartDelay(2000);
//        animator4.setStartDelay(2000);
        /**
         * anim1，anim2,anim3同时执行
         * anim4接着执行
         */
        AnimatorSet animSet = new AnimatorSet();
        animSet.play(animator1).with(animator2).with(animator3).with(animator4);
        animSet.setDuration(4000);
        animSet.start();
        animSet.addListener(new Animator.AnimatorListener() {
            @Override
            public void onAnimationStart(Animator animator) {

            }

            @Override
            public void onAnimationEnd(Animator animator) {
//            container.startAnimation(createAlphaAnimation());
//            container.setVisibility(View.INVISIBLE);//动画结束时，揭露动画设置为不可见
//                dialog.setVisibility(View.INVISIBLE);
            }

            @Override
            public void onAnimationCancel(Animator animator) {

            }

            @Override
            public void onAnimationRepeat(Animator animator) {

            }
        });
    }


}
